官方範例-Markdown編輯
25.php
<html>
<head>
<meta charset="UTF-8">
<title>官方範例-Markdown編輯</title>
</head>
<body>
<div id="show">
<textarea :value="input" @input="update"></textarea>
<div v-html="compiledMarkdown"></div>
</div>
</body>
<script src="https://unpkg.com/marked@0.3.6"></script>
<script src="https://unpkg.com/lodash@4.16.0"></script>
<script src="vue.js"></script>
<script>
new Vue({
el: '#show',
data: {
input: '# hello'
},
computed: {
compiledMarkdown: function () {
return marked(this.input, {sanitize: true})
}
},
methods: {
update: _.debounce(function (e) {
this.input = e.target.value
}, 300)
}
})
</script>
</html>